package bigdata_remote

import (
	"context"
	"errors"
	"git.mycaigou.com/gfyx/common/http_client"
	"git.mycaigou.com/gfyx/common/simplecopier"
)

type bigdataRepository struct{}

const (
	GetIndustryTagUri                           = "/big-data/gfyx/developer/industry_tag"
	GetSupplierProjectUri                       = "/big-data/supplier/project-list"
	GetInvestCompanyUri                         = "/big-data/gfyx/developer/get-invest-tree"
	GetFeedUri                                  = "/big-data/gfyx/developer/feed-list"
	GetPurchaseBaseUri                          = "/big-data/gfyx/purchase/base"
	GetCooperationCompanyUri                    = "/big-data/gfyx/developer/get-cooperation-company"
	GetFilterListUrl                            = "/big-data/gfyx/option/list"
	GetProjectListUri                           = "/big-data/gfyx/project/list"
	GetProjectDetailLandUri                     = "/big-data/gfyx/project-detail/land"
	GetStatisticsDataUri                        = "/big-data/gfyx/statistics/data"
	GetCustomerDynamicTotal                     = "/big-data/gfyx/statistics/customer-dynamic-total"
	GetProjectDetailBuildUri                    = "/big-data/gfyx/project-detail/build"
	GetProjectDetailSaleUri                     = "/big-data/gfyx/project-detail/sale"
	GetProjectDetailBidUri                      = "/big-data/gfyx/project-detail/bid"
	GetBuildingDetailBasicUri                   = "/big-data/gfyx/building-detail/basic"                 // 获取在建项目详情-基本信息
	GetBuildingDetailTargetNumUri               = "/big-data/gfyx/building-detail/target-num"            // 获取在建项目详情-指标
	GetBuildingDetailBidUri                     = "/big-data/gfyx/building-detail/bid"                   // 获取在建项目详情-招标
	GetBuildingDetailParticipatingUnitsBasicUri = "/big-data/gfyx/building-detail/participating-units"   // 获取在建项目详情-合作单位
	GetBuildingDetailContractListUri            = "/big-data/gfyx/building-detail/contract-list"         // 获取在建项目详情-合同登记列表
	GetBuildingDetailWorkingDrawingAuditUri     = "/big-data/gfyx/building-detail/working-drawing-audit" // 在建项目详情-获取施工图审列表
	GetBuildingDetailConstructionPermitUri      = "/big-data/gfyx/building-detail/construction-permit"   // 在建项目详情-施工许可列表
	GetBuildingDetailCompletionFilingUri        = "/big-data/gfyx/building-detail/completion-filing"     // 在建项目详情-竣工备案列表
	GetBidListUri                               = "/big-data/gfyx/bid/list"
	GetTradingCenterBidUri                      = "/big-data/gfyx/bid/trading-center"
	GetWinBidUri                                = "/big-data/gfyx/winbid/list"
	GetTakenLandListUri                         = "/big-data/gfyx/taken-land/list"
	GetSaleDataListUri                          = "/big-data/gfyx/sale/list"
	GetTopProjectUri                            = "/big-data/gfyx/top-project/list"
	GetNewHouseUri                              = "/big-data/gfyx/sale/new_house"
	GetCompanyTargetUri                         = "/big-data/gfyx/company/target"
	GetUseRankListUri                           = "/big-data/sentry/use-num-rank"
)

const (
	//人群：并且关系
	GetAndWinbidCrowdUri           = "/big-data/gfyx/outbound/and-winbid-crowd"
	GetAndWinbidCrowdContactUri    = "/big-data/gfyx/outbound/and-winbid-crowd-contact"
	GetAndDeveloperCrowdUri        = "/big-data/gfyx/outbound/and-developer-crowd"
	GetAndDeveloperCrowdContactUri = "/big-data/gfyx/outbound/and-developer-crowd-contact"

	//人群：或者关系
	GetOrWinbidCrowdUri           = "/big-data/gfyx/outbound/or-winbid-crowd"
	GetOrWinbidCrowdContactUri    = "/big-data/gfyx/outbound/or-winbid-crowd-contact"
	GetOrDeveloperCrowdUri        = "/big-data/gfyx/outbound/or-developer-crowd"
	GetOrDeveloperCrowdContactUri = "/big-data/gfyx/outbound/or-developer-crowd-contact"

	//rpa联系人
	GetCrowdByRpaUri = "/big-data/gfyx/rcc/get-contact-list"
)

const LogicTypeAll = "全部"
const LogicTypeAny = "任一"

func NewBigDataServiceRepo() BigDataServiceRepositoryIface {
	return &bigdataRepository{}
}

func (r *bigdataRepository) GetIndustryTag(ctx context.Context, request *GetIndustryCategoryRequest) (*GetIndustryCategoryData, error) {
	client := http_client.NewDataServiceClient()

	response := GetIndustryCategoryResponse{}
	_, _, errs := client.Post(ctx, GetIndustryTagUri, map[string]interface{}{"page": request.Page, "page_size": request.PageSize}, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}

	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) GetStatisticsData(ctx context.Context, request *GetStatisticsDataRequest) (*StatisticsDataData, error) {
	client := http_client.NewDataServiceClient()
	response := GetStatisticsDataResponse{}
	requestMap, _ := simplecopier.StructToMapByJsonTag(request)
	_, _, errs := client.Post(ctx, GetStatisticsDataUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}

	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) GetCustomerDynamicTotal(ctx context.Context, request *GetCustomerDynamicTotalRequest) (*CustomerDynamicTotalData, error) {
	client := http_client.NewDataServiceClient()
	response := GetCustomerDynamicTotalResponse{}
	requestMap, _ := simplecopier.StructToMapByJsonTag(request)
	_, _, errs := client.Post(ctx, GetCustomerDynamicTotal, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}

	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) GetSupplierProject(ctx context.Context, request *SupplierProjectRequest) (*SupplierProjectData, error) {
	client := http_client.NewDataServiceClient()
	response := SupplierProjectResponse{}
	requestMap, _ := simplecopier.StructToMapByJsonTag(request)
	_, _, errs := client.Post(ctx, GetSupplierProjectUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) GetInvestCompany(ctx context.Context, request *GetInvestCompanyRequest) (*GetInvestCompanyData, error) {
	client := http_client.NewDataServiceClient()
	response := GetInvestCompanyResponse{}
	requestMap, _ := simplecopier.StructToMapByJsonTag(request)
	_, _, errs := client.Post(ctx, GetInvestCompanyUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) GetInvestCompanyCodes(ctx context.Context, organizingCode string) ([]string, error) {
	if organizingCode == "" {
		return nil, nil
	}

	var investCompanyCodes []string
	investCompanyData, _ := r.GetInvestCompany(ctx, &GetInvestCompanyRequest{OrganizingCode: organizingCode, PageNum: 1, PageSize: 10000})
	if investCompanyData != nil && len(investCompanyData.List) > 0 {
		for _, investV := range investCompanyData.List {
			if investV.SubOrganizingCode != "" {
				investCompanyCodes = append(investCompanyCodes, investV.SubOrganizingCode)
			}
		}
	}

	// 无子公司，返回本公司社会信用代码
	if len(investCompanyCodes) == 0 {
		investCompanyCodes = append(investCompanyCodes, organizingCode)
	}

	return investCompanyCodes, nil
}

func (r *bigdataRepository) GetFeed(ctx context.Context, request *GetFeedRequest) (*GetFeedData, error) {
	client := http_client.NewDataServiceClient()
	response := GetFeedResponse{}
	requestMap, _ := simplecopier.StructToMapByJsonTag(request)
	_, _, errs := client.Post(ctx, GetFeedUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) GetPurchaseBase(ctx context.Context, request *GetPurchaseBaseRequest) (*GetPurchaseBaseData, error) {
	client := http_client.NewDataServiceClient()
	response := GetPurchaseBaseResponse{}
	requestMap, _ := simplecopier.StructToMapByJsonTag(request)
	_, _, errs := client.Post(ctx, GetPurchaseBaseUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) GetCooperationCompany(ctx context.Context, request *GetCooperationCompanyRequest) (*GetCooperationCompanyData, error) {
	client := http_client.NewDataServiceClient()
	response := GetCooperationCompanyResponse{}
	requestMap, _ := simplecopier.StructToMapByJsonTag(request)
	_, _, errs := client.Post(ctx, GetCooperationCompanyUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) GetFilterList(ctx context.Context, request *GetFilterListRequest) (*GetFilterListData, error) {
	client := http_client.NewDataServiceClient()
	response := GetFilterListResponse{}
	requestMap, _ := simplecopier.StructToMapByJsonTag(request)
	_, _, errs := client.Post(ctx, GetFilterListUrl, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) GetCrowdByWinbid(ctx context.Context, request *GetCrowdByWinbidRequest, logicType string) (*GetCrowdByWinbidData, error) {
	uri := ""
	if logicType == LogicTypeAll {
		uri = GetAndWinbidCrowdUri
	} else {
		uri = GetOrWinbidCrowdUri
	}
	client := http_client.NewDataServiceClient()
	response := GetCrowdByWinbidResponse{}
	requestMap, _ := simplecopier.StructToMapByJsonTag(request)
	_, _, errs := client.Post(ctx, uri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) GetCrowdByDeveloper(ctx context.Context, request *GetCrowdByDeveloperRequest, logicType string) (*GetCrowdByDeveloperData, error) {
	uri := ""
	if logicType == LogicTypeAll {
		uri = GetAndDeveloperCrowdUri
	} else {
		uri = GetOrDeveloperCrowdUri
	}
	client := http_client.NewDataServiceClient()
	response := GetCrowdByDeveloperResponse{}
	requestMap, _ := simplecopier.StructToMapByJsonTag(request)
	_, _, errs := client.Post(ctx, uri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) GetCrowdByRpa(ctx context.Context, request *GetCrowdByRpaRequest) (*GetCrowdByRpaData, error) {
	client := http_client.NewDataServiceClient()
	response := GetCrowdByRpaResponse{}
	requestMap, _ := simplecopier.StructToMapByJsonTag(request)
	_, _, errs := client.Post(ctx, GetCrowdByRpaUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) GetCrowdTotalByWinbid(ctx context.Context, request *GetCrowdTotalByWinbidRequest, logicType string) (*GetCrowdTotalByWinbidData, error) {
	uri := ""
	if logicType == LogicTypeAll {
		uri = GetAndWinbidCrowdContactUri
	} else {
		uri = GetOrWinbidCrowdContactUri
	}

	client := http_client.NewDataServiceClient()
	response := GetCrowdTotalByWinbidResponse{}
	requestMap, _ := simplecopier.StructToMapByJsonTag(request)
	_, _, errs := client.Post(ctx, uri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) GetCrowdTotalByDeveloper(ctx context.Context, request *GetCrowdTotalByDeveloperRequest, logicType string) (*GetCrowdTotalByDeveloperData, error) {
	uri := ""
	if logicType == LogicTypeAll {
		uri = GetAndDeveloperCrowdContactUri
	} else {
		uri = GetOrDeveloperCrowdContactUri
	}
	client := http_client.NewDataServiceClient()
	response := GetCrowdTotalByDeveloperResponse{}
	requestMap, _ := simplecopier.StructToMapByJsonTag(request)
	_, _, errs := client.Post(ctx, uri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) GetProjectList(ctx context.Context, request *GetProjectListRequest) (*GetProjectListData, error) {
	client := http_client.NewDataServiceClient()
	response := GetProjectListResponse{}
	requestMap, _ := simplecopier.StructToMapByJsonTag(request)
	_, _, errs := client.Post(ctx, GetProjectListUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) ProjectDetailLand(ctx context.Context, request *ProjectDetailLandRequest) (*ProjectDetailLandData, error) {
	client := http_client.NewDataServiceClient()
	response := ProjectDetailLandResponse{}
	requestMap, _ := simplecopier.StructToMapByJsonTag(request)
	_, _, errs := client.Post(ctx, GetProjectDetailLandUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) ProjectDetailBuild(ctx context.Context, request *ProjectDetailBuildRequest) (*ProjectDetailBuildData, error) {
	client := http_client.NewDataServiceClient()
	response := ProjectDetailBuildResponse{}
	requestMap, _ := simplecopier.StructToMapByJsonTag(request)
	_, _, errs := client.Post(ctx, GetProjectDetailBuildUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) ProjectDetailSale(ctx context.Context, request *ProjectDetailSaleRequest) (*ProjectDetailSaleData, error) {
	client := http_client.NewDataServiceClient()
	response := ProjectDetailSaleResponse{}
	requestMap, _ := simplecopier.StructToMapByJsonTag(request)
	_, _, errs := client.Post(ctx, GetProjectDetailSaleUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) ProjectDetailBid(ctx context.Context, request *ProjectDetailBidRequest) (*ProjectDetailBidData, error) {
	client := http_client.NewDataServiceClient()
	response := ProjectDetailBidResponse{}
	requestMap, _ := simplecopier.StructToMapByJsonTag(request)
	_, _, errs := client.Post(ctx, GetProjectDetailBidUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) BidList(ctx context.Context, request *BidListRequest) (*BidListData, error) {
	client := http_client.NewDataServiceClient()
	response := BidListResponse{}
	requestMap, _ := simplecopier.StructToMapByJsonTag(request)
	_, _, errs := client.Post(ctx, GetBidListUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) TradingCenterBid(ctx context.Context, request *TradingCenterBidRequest) (*TradingCenterBidData, error) {
	client := http_client.NewDataServiceClient()
	response := TradingCenterBidResponse{}
	requestMap, _ := simplecopier.StructToMapByJsonTag(request)
	_, _, errs := client.Post(ctx, GetTradingCenterBidUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) WinBidList(ctx context.Context, request *WinBidListRequest) (*WinBidListData, error) {
	client := http_client.NewDataServiceClient()
	response := WinBidListResponse{}
	requestMap, _ := simplecopier.StructToMapByJsonTag(request)
	_, _, errs := client.Post(ctx, GetWinBidUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) TakenLandList(ctx context.Context, request *TakenLandListRequest) (*TakenLandListData, error) {
	client := http_client.NewDataServiceClient()
	response := TakenLandListResponse{}
	requestMap, _ := simplecopier.StructToMapByJsonTag(request)
	_, _, errs := client.Post(ctx, GetTakenLandListUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}
func (r *bigdataRepository) SaleList(ctx context.Context, request *SaleListRequest) (*SaleListData, error) {
	client := http_client.NewDataServiceClient()
	response := SaleListResponse{}
	requestMap, _ := simplecopier.StructToMapByJsonTag(request)
	_, _, errs := client.Post(ctx, GetSaleDataListUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}
func (r *bigdataRepository) NewHouse(ctx context.Context, request *NewHouseRequest) (*NewHouseData, error) {
	client := http_client.NewDataServiceClient()
	response := NewHouseResponse{}
	requestMap, _ := simplecopier.StructToMapByJsonTag(request)
	_, _, errs := client.Post(ctx, GetNewHouseUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}
func (r *bigdataRepository) GetTopProject(ctx context.Context, request *GetTopProjectRequest) (*GetTopProjectData, error) {
	client := http_client.NewDataServiceClient()
	response := GetTopProjectResponse{}
	requestMap, _ := simplecopier.StructToMapByJsonTag(request)
	_, _, errs := client.Post(ctx, GetTopProjectUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) GetCompanyTarget(ctx context.Context, request *GetCompanyTargetRequest) (*GetCompanyTargetData, error) {
	client := http_client.NewDataServiceClient()
	response := GetCompanyTargetResponse{}
	requestMap, _ := simplecopier.StructToMapByJsonTag(request)
	_, _, errs := client.Post(ctx, GetCompanyTargetUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

// GetBuildingDetailBasic 获取招标详情数据
func (r *bigdataRepository) GetBuildingDetailBasic(ctx context.Context, request *GetBuildingDetailRequest) (*GetBuildingDetailBasicItem, error) {
	client := http_client.NewDataServiceClient()
	response := GetBuildingDetailBasicResponse{}
	requestMap := map[string]interface{}{
		"id": request.Id,
	}
	_, _, errs := client.Post(ctx, GetBuildingDetailBasicUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	if response.Data != nil && len(response.Data.List) > 0 {
		return response.Data.List[0], nil
	}
	return nil, errors.New("找不到该记录")
}

func (r *bigdataRepository) GetBuildingDetailTargetNum(ctx context.Context, request *GetBuildingDetailRequest) (*GetBuildingDetailTargetNumItem, error) {
	client := http_client.NewDataServiceClient()
	response := GetBuildingDetailTargetNumResponse{}
	requestMap := map[string]interface{}{
		"id": request.Id,
	}
	_, _, errs := client.Post(ctx, GetBuildingDetailTargetNumUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	if response.Data != nil && len(response.Data.List) > 0 {
		return response.Data.List[0], nil
	}
	return nil, errors.New("找不到指标记录")
}

func (r *bigdataRepository) GetBuildingDetailBidList(ctx context.Context, request *GetBuildingDetailRequest) (*GetBuildingDetailBidData, error) {
	client := http_client.NewDataServiceClient()
	response := GetBuildingDetailBidResponse{}
	requestMap := map[string]interface{}{
		"id":        request.Id,
		"page":      request.Page,
		"page_size": request.PageSize,
	}
	_, _, errs := client.Post(ctx, GetBuildingDetailBidUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) GetBuildingDetailParticipatingUnits(ctx context.Context, request *GetBuildingDetailRequest) (*GetBuildingDetailParticipatingUnitsData, error) {
	client := http_client.NewDataServiceClient()
	response := GetBuildingDetailParticipatingUnitsResponse{}
	requestMap := map[string]interface{}{
		"id":        request.Id,
		"page":      request.Page,
		"page_size": request.PageSize,
	}
	_, _, errs := client.Post(ctx, GetBuildingDetailParticipatingUnitsBasicUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) GetBuildingDetailContractList(ctx context.Context, request *GetBuildingDetailRequest) (*GetBuildingDetailContractListData, error) {
	client := http_client.NewDataServiceClient()
	response := GetBuildingDetailContractListResponse{}
	requestMap := map[string]interface{}{
		"id":        request.Id,
		"page":      request.Page,
		"page_size": request.PageSize,
	}
	_, _, errs := client.Post(ctx, GetBuildingDetailContractListUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) GetBuildingDetailWorkingDrawingAudit(ctx context.Context, request *GetBuildingDetailRequest) (*GetBuildingDetailWorkingDrawingAuditData, error) {
	client := http_client.NewDataServiceClient()
	response := GetBuildingDetailWorkingDrawingAuditResponse{}
	requestMap := map[string]interface{}{
		"id":        request.Id,
		"page":      request.Page,
		"page_size": request.PageSize,
	}
	_, _, errs := client.Post(ctx, GetBuildingDetailWorkingDrawingAuditUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) GetBuildingDetailConstructionPermit(ctx context.Context, request *GetBuildingDetailRequest) (*GetBuildingDetailConstructionPermitData, error) {
	client := http_client.NewDataServiceClient()
	response := GetBuildingDetailConstructionPermitResponse{}
	requestMap := map[string]interface{}{
		"id":        request.Id,
		"page":      request.Page,
		"page_size": request.PageSize,
	}
	_, _, errs := client.Post(ctx, GetBuildingDetailConstructionPermitUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) GetBuildingDetailCompletionFiling(ctx context.Context, request *GetBuildingDetailRequest) (*GetBuildingDetailCompletionFilingData, error) {
	client := http_client.NewDataServiceClient()
	response := GetBuildingDetailCompletionFilingResponse{}
	requestMap := map[string]interface{}{
		"id":        request.Id,
		"page":      request.Page,
		"page_size": request.PageSize,
	}
	_, _, errs := client.Post(ctx, GetBuildingDetailCompletionFilingUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}

func (r *bigdataRepository) GetUseRankList(ctx context.Context, request *GetUseRankListRequest) (*GetUseRankListData, error) {
	client := http_client.NewDataServiceClient()
	requestMap := map[string]interface{}{
		"tenant_code": request.TenantCode,
		"start_date":  request.StartDate,
		"page":        request.Page,
		"page_size":   request.PageSize,
	}

	response := GetUseRankListResponse{}
	_, _, errs := client.Post(ctx, GetUseRankListUri, requestMap, nil).EndStruct(&response)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	if response.Success == false {
		return nil, errors.New(response.Message)
	}
	return response.Data, nil
}
